<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="navbar.jsp" %> 
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   
    
    <title>My JSP 'document.jsp' starting page</title>
   <link rel="stylesheet" type="text/css" href="styles/css/bootstrap.min.css" />
   
  </head>
  
  <body class="body">
    <div class="container"style="margin-top:60px;width:960px;margin-left:auto;margin-right:auto;">

	  <div class="row">
	
	
		<!-- 导入左侧部分 -->
		<jsp:include page="side.jsp">
			<jsp:param value="document" name="tag"/>
		</jsp:include>
	
	
		<div class="span9">
			<ul class="breadcrumb" style="margin-bottom:0px;border-radius: 3px 3px 0 0;margin-top:15px">
				<li class="active">

					<a href="document.jspx"><i class="icon-folder-open"></i>资料</a>
				</li>
				<li class="pull-right"><i class="icon-plus"></i><a href="document.jspx?m=add" class="link-black">分享新资料</a></li>
			</ul>
			<div class="wall" style="margin-bottom:20px;border:1px solid #ddd;padding:15px">
				
			<c:forEach items="${requestScope.documentpage.result }" var="d">
				<blockquote>
				  <h4><a href="document.jspx?m=show&id=${d.documentId }&p=${param.p}">${d.documentName }</a></h4>
				 
				 
				 
				 <!-- 当资料字符长度大于200时，只显示200个字符的长度 -->
				  <c:choose>
				  	<c:when test="${d.desc.length() > 200 }">
				  		 <p style="font-size:14px;line-height:1.5;">${d.desc.substring(0,200) }</p>
				  	</c:when>
				  	<c:otherwise>
				  		  <p style="font-size:14px;line-height:1.5;">${d.desc }</p>
				  	</c:otherwise>
				  </c:choose>
				  
				  <small>${d.user.userName }发布于${d.time }</small>
				 
				 
				 <!-- 只有资料发布人才有资格修改和删除资料 -->
				 <c:choose>
				 	<c:when test="${d.user.userName == sessionScope.user.userName }">
				 		<a href="document.jspx?m=update&id=${d.documentId }" title="编辑"><i class="icon-pencil"></i></a>
					    <a href="document.jspx?m=del&id=${d.documentId }" title="删除"><i class="icon-trash"></i></a>
				 	</c:when>
				 </c:choose>
				  
				</blockquote>
			</c:forEach>
			
			
			
			
			
			
			<!--以下是分页功能，在页面显示靠右时使用 pagination-right而不是pull-right -->
			    <div class="pagination pagination-right">
				    <ul>
				    	<c:choose>
					  		<c:when test="${requestScope.documentpage.pageNum == 1 }">
					  			 <li><a href="#">首页</a></li>
					  		</c:when>
					  		<c:otherwise>
					  			<li><a href="document.jspx?p=1">首页</a></li>
					  		</c:otherwise>
					  	</c:choose>
					  	<c:choose>
					  		<c:when test="${requestScope.documentpage.pageNum == 1}">
					  			<li><a href="#">上一页</a></li>
					  		</c:when>
					  		<c:otherwise>
					  			<li><a href="document.jspx?p=${requestScope.documentpage.pageNum - 1 }">上一页</a></li>
					  		</c:otherwise>
					  	</c:choose>
					  	<c:choose>
					  		<c:when test="${requestScope.documentpage.pageNum == requetScope.documentpage.totalPages }">
					  			<li><a href="#">下一页</a></li>
					  		</c:when>
					  		<c:otherwise>
					  			<li><a href="document.jspx?p=${requestScope.documentpage.pageNum + 1 }">下一页</a></li>
					  		</c:otherwise>
					  	</c:choose>
					  	<c:choose>
					  		<c:when test="${requestScope.documentpage.pageNum == requestScope.documentpage.totalPages }">
					  			<li><a href="#">尾页</a></li>
					  		</c:when>
					  		<c:otherwise>
					  			<li><a href="document.jspx?p=${requestScope.documentpage.totalPages }">尾页</a></li>
					  		</c:otherwise>
					  	</c:choose>
					   
					  
				    </ul>
				    </div>														
				
		</div>
			
			
  	
		</div>
	  </div>
	</div>
	
	
	
	
	
	
	
	
  </body>
</html>
